package com.link2room.soundwave.controller.manager;

import com.link2room.common.dto.result.base.BaseResultDto;
import com.link2room.sideswipe.permissionResouces.annotation.L2RPermissionResources;
import com.link2room.soundwave.dto.param.base.PmsRateParamDto;
import com.link2room.soundwave.util.HandlerUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import static com.link2room.soundwave.constant.PermissionConstant.syncPMSRates;

/**
 * Created by VegetaKo on 2016/11/15.
 */
@Api(tags = "PMS同步管理")
@RestController
@RequestMapping("/manager/Sync")
public class PMSRateManagerController {

    @ApiOperation(value ="同步PMS房价")
    @RequestMapping(value="/SyncPMSRates" ,method = RequestMethod.GET)
    @L2RPermissionResources(value = syncPMSRates, name = "同步PMS价格")
    public BaseResultDto syncPMSRates(
            @RequestParam(value = "lhotelCode", required = false) String lhotelCode,
            @RequestParam(value = "dayStep", required = false) Long dayStep,
            @RequestParam(value = "isOverride", required = false) String isOverride
    ) throws Exception{
        PmsRateParamDto baseL2rParamDto=new PmsRateParamDto();
        baseL2rParamDto.setLhotelCode(lhotelCode);
        baseL2rParamDto.setDayStep(dayStep);
        baseL2rParamDto.setIsOverride(isOverride);
        HandlerUtil.pmsRateHandler().syncPMSRateHandler(baseL2rParamDto);
        BaseResultDto baseResultDto = new BaseResultDto();
        baseResultDto.setResultCode(0);
        return  baseResultDto;
    }
}
